package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


@Getter
@Setter
public class Customize {

    public static final int SELF =1;//自己
    public static final int FAMILY =2;//家庭
    public static final int COMPANY =3;//公司团建
    public static final int COUPLE =4;//情侣
    public static final int FRIEND =5;//密友

    public static final int QIANZAI =10;//潜在
    public static final int SUCCESS =11;//刚签约
    public static final int AFTER =12;//服务之后的客户


    private Long id;//主键id

    private User user;//用户id

    private int customType;//私人客户类型

    private Integer passengerAdult;//成人数量

    private Integer passengerChild;//儿童数量

    private Region srcplace;//出发地id

    private Region destplace;//目标地id

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date begintime;//旅游开始时间

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endtime;//旅游结束时间

    private Long estimatedcost;//预算费用

    private Long tel;//联系人电话

    private String other;//客户其他需求

    private Integer state;//客户状态

    public String getJsonString(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        if(user!=null){
            map.put("userId",user.getId());
            map.put("userNickName",user.getNickName());
        }
        map.put("customType",customType);
        map.put("passengerAdult",passengerAdult);
        map.put("passengerChild",passengerChild);
//        map.put("srcplace",srcplace);
//        map.put("destplace",destplace);
        map.put("endtime",endtime);
        map.put("begintime",begintime);
        map.put("tel",tel);
        map.put("other",other);
        map.put("state",state);
        map.put("estimatedcost",estimatedcost);
        return JSONUtils.toJSONString(map);
    }

    public String getCustomTypeDisplay(){
        if(customType==SELF){
            return "自己";
        }else if(customType==FAMILY){
            return "家庭";

        }else if(customType==COMPANY){
            return "公司团建";
        }
        else if(customType==COUPLE){
            return "情侣";

        }else if(customType==FRIEND){
            return "密友";
        }else {
        return "其他";
        }
    }
    public String getstateDisplay(){
        if(state==QIANZAI){
            return "潜在";
        }else if(state==SUCCESS){
            return "刚签约";

        }else if(state==AFTER){
            return "服务之后的客户";
        }else {
            return "";
        }

    }
}